// @ts-ignore
import { api } from '@/utils/api';

/** 获取redis信息 GET /cache/monitor/info/redis */
export async function cacheMonitorInfoRedis(
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultListRedisInfo>;

export async function cacheMonitorInfoRedis(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultListRedisInfo>>;

export async function cacheMonitorInfoRedis(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultListRedisInfo>;

export async function cacheMonitorInfoRedis(options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultListRedisInfo>(`/app/cache/monitor/info/redis`, {
      method: 'GET',
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultListRedisInfo>(`/app/cache/monitor/info/redis`, {
    method: 'GET',
    ...(options || {})
  });
}

/** 获取本地缓存大小 GET /cache/monitor/size/local */
export async function cacheMonitorSizeLocal(
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultCacheSize>;

export async function cacheMonitorSizeLocal(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultCacheSize>>;

export async function cacheMonitorSizeLocal(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultCacheSize>;

export async function cacheMonitorSizeLocal(options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultCacheSize>(`/app/cache/monitor/size/local`, {
      method: 'GET',
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultCacheSize>(`/app/cache/monitor/size/local`, {
    method: 'GET',
    ...(options || {})
  });
}

/** 获取redis缓存大小 GET /cache/monitor/size/redis */
export async function cacheMonitorSizeRedis(
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultCacheSize>;

export async function cacheMonitorSizeRedis(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultCacheSize>>;

export async function cacheMonitorSizeRedis(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultCacheSize>;

export async function cacheMonitorSizeRedis(options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultCacheSize>(`/app/cache/monitor/size/redis`, {
      method: 'GET',
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultCacheSize>(`/app/cache/monitor/size/redis`, {
    method: 'GET',
    ...(options || {})
  });
}
